package com.ruoyi.web.controller.qiushi.system;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.qiushi.domain.system.QiushiFeedback;
import com.ruoyi.qiushi.service.system.IQiushiFeedbackService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 意见反馈Controller
 *
 * @author ruoyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/qiushi/system/qiushifeedback")
public class QiushiFeedbackController extends BaseController {
    @Autowired
    private IQiushiFeedbackService qiushiFeedbackService;

    /**
     * 查询意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(QiushiFeedback qiushiFeedback) {
        startPage();
        List<QiushiFeedback> list = qiushiFeedbackService.selectQiushiFeedbackList(qiushiFeedback);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:export')")
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QiushiFeedback qiushiFeedback) {
        List<QiushiFeedback> list = qiushiFeedbackService.selectQiushiFeedbackList(qiushiFeedback);
        ExcelUtil<QiushiFeedback> util = new ExcelUtil<QiushiFeedback>(QiushiFeedback.class);
        util.exportExcel(response, list, "意见反馈数据");
    }

    /**
     * 获取意见反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(qiushiFeedbackService.selectQiushiFeedbackById(id));
    }

    /**
     * 新增意见反馈
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:add')")
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QiushiFeedback qiushiFeedback) {
        qiushiFeedback.setUpdateTime(new Date());
        return toAjax(qiushiFeedbackService.insertQiushiFeedback(qiushiFeedback));
    }

    /**
     * 修改意见反馈
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:edit')")
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QiushiFeedback qiushiFeedback) {
        return toAjax(qiushiFeedbackService.updateQiushiFeedback(qiushiFeedback));
    }

    /**
     * 删除意见反馈
     */
    @PreAuthorize("@ss.hasPermi('qiushi:system:qiushifeedback:remove')")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(qiushiFeedbackService.deleteQiushiFeedbackById(id));
    }
}
